//
//  AppDelegate+UMShare.m
//  TomatoDemo
//
//  Created by MiniC on 15-6-30.
//  Copyright (c) 2014年 hongjian_feng. All rights reserved.
//


#import "AppDelegate+UMShare.h"
// 友盟头文件
#import <UMSocialCore/UMSocialCore.h>
#import "UMSocialSinaHandler.h"
#import "UMSocialWechatHandler.h"
#import "UMSocialQQHandler.h"
#import "WXApi.h"
//#import "WeiboSDK.h"

@implementation AppDelegate (UMShare)

- (void)initUMeng {

    //打开调试log的开关
    /* 打开调试日志 */
    [[UMSocialManager defaultManager] openLog:YES];
    /* 设置友盟appkey */
    [[UMSocialManager defaultManager] setUmSocialAppkey:UmengAppkey];
    
    [self confitUShareSettings];
    
    //友盟日志分析
    UMConfigInstance.appKey = UmengAppkey;
    [MobClick startWithConfigure:UMConfigInstance];//配置以上参数后调用此方法初始化SDK
    [MobClick setAppVersion:[[IGServerConfig sharedConfig] appVersion]];
}

- (void)confitUShareSettings {
    [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_WechatSession appKey:weiXinAppId appSecret:weiXinAppSecret redirectURL:nil];
    
    [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_QQ appKey:tencentAppid  appSecret:tencentConnectAppkey redirectURL:@"http://mobile.umeng.com/social"];
    
    [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_Sina appKey:sinaAppKey appSecret:sinaAppSecret redirectURL:kRedirectURI];
}

/**
 这里处理新浪微博SSO授权进入新浪微博客户端后进入后台，再返回原来应用
 */
- (void)applicationDidBecomeActive:(UIApplication *)application
{
//    [UMSocialSnsService applicationDidBecomeActive];
}

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{

    BOOL result = [[UMSocialManager defaultManager] handleOpenURL:url sourceApplication:nil annotation:nil];
    
    return [WXApi handleOpenURL:url delegate:nil] || result;
}

- (BOOL)UMengActionWithUrl:(NSURL *)url{
    return [[UMSocialManager defaultManager] handleOpenURL:url sourceApplication:nil annotation:nil];
}

@end
